# Maintainer: Jelle van der Waa <jelle@archlinux.org>

pkgname=python-pytest-snapshot
_name=${pkgname#python-}
pkgver=0.9.0
pkgrel=1
pkgdesc="A plugin for snapshot testing with pytest."
arch=('any')
url="https://github.com/joseph-roitman/pytest-snapshot"
license=('MIT')
depends=(python)
makedepends=(python-build python-installer python-setuptools
	     python-setuptools-scm python-wheel)
depends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/joseph-roitman/pytest-snapshot/archive/refs/tags/v${pkgver}.tar.gz"
	"adjust-pytest-output.patch")
sha512sums=('ff77e0977c5ca6d956a72a1d2cce2c285bcfee3c76c9d58cd6d881643c889246488d1b5910b2319a283bf026defc51b729046aaad609416c1b71fb4c19ce9ecb'
            'ffcdf0764cc0094ce3e6df86d86c30abb72b7736180a4d5aa7650bf7432c881708dccd6d812f5de83cd03afa44285018588c05c050bf04252f76255a2f774538')

prepare() {
    cd $_name-$pkgver
    patch -Np2 -i ${srcdir}/adjust-pytest-output.patch
}

check() {
    cd $_name-$pkgver
    PYTHONPATH=. pytest -k 'not test_sth' tests
}

build() {
    cd $_name-$pkgver
    export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver

    python -m build --wheel --no-isolation
}

package() {
    cd $_name-$pkgver

    python -m installer --destdir="$pkgdir" dist/*.whl
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
